import java.util.HashMap;
import java.util.Map;


public class SecurityManager {
    private Map<String, User> users;
    
    public SecurityManager() {
        users = new HashMap<String, User>();
    }
    
    public User findUser(String name) {
        return users.get(name);
    }
    
    public PasswordResponse doLogin(String uid, String pwd) {
        if (uid == null) return PasswordResponse.BAD_UID;
        User user = users.get(uid);
        if (user == null) return PasswordResponse.BAD_UID;
        if (user.checkPassword(pwd)) {
            return PasswordResponse.GOOD_LOGIN;
        }
        return PasswordResponse.BAD_PASSWORD;
    }
    
    public void addUser(User u) {
    	users.put(u.getUid(), u);
    }

}
